<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="theme/Header.jsp" %>
<script type="text/javascript" >
    $().ready(function() {
        $('#province').val('${province}');
        $('#execute').click(function(){
            $('#p').val('1');
            submit();
        });

        $("#frm_gov001").validate({
            rules: {
                plate: "required" ,
                province: "required"
            },
            messages: {
                plate: " ***กรุณาใส่ทะเบียนรถ" ,
                province: " ***กรุณาเลือกจังหวัด"
            }
        });

        $('#add').click(function(){
            window.location = "GOV001_DISPLAY_ADD";
        });

        $('#clear').click(function() {
            $('#uname').val('');
            $('#udesc').val('');
        });
    });

    function doDel(id) {
        if (confirm("Are you sure you want to delete")) {
            window.location = "GOV001_DELETE?id=" + id + "&p=${p}";
        }
    }

    function edit(plate,prov) {
        window.location = "GOV001_DISPLAY_EDIT?plate=" + plate + "&prov=" + prov;
    }

    function submit() {
        $('#frm_gov001').submit();
    }
</script>
<div id="site-root">
    <div>
        <a href="GOV001Manage">[GOV001- ข้อมูลรถจากขนส่ง]</a>
    </div>
</div>
<div id="button-bar">
    <fieldset>
        <div class="buttons">
            <button class="positive" id="execute">
                <img  src="theme/images/icons/search.gif" alt="" width="16" height="16"/>ค้นหาข้อมูล
            </button>
            <button class="positive" id="add" >
                <img  src="theme/images/icons/action_add.gif" alt="" width="16" height="16"  />เพิ่มข้อมูล
            </button>
        </div>
    </fieldset>
</div>
<div id="source-data">
    <fieldset style="background: #FFF">
        <legend>รายละเอียดการค้นหา</legend>
        <form action="GOV001Display" id="frm_gov001" method="post" class="cmxform">
            <table width="100%" cellpadding="1">
                <tr>
                    <td width="100px" align="right">หมายเลขทะเบียน : </td>
                    <td width="350px">
                        <input type="text" id="plate" name="plate"
                               value="${plate}" size="30" class="require"/>
                    </td>
                </tr>
                <tr>
                    <td align="right">จังหวัด : </td>
                    <td>
                        <select id="province" name="province" class="require" tabindex="11" >
                            <option value="" selected>เลือกจังหวัด</option>
                            <c:forEach items="${provinceList}" var="p" varStatus="i">
                                <option value="${p.provinceName}">${p.provinceName}</option>
                            </c:forEach>
                        </select>
                    </td>
                </tr>
            </table>

            <input type="hidden" id="p" name="p" value="${p}" />
        </form>
    </fieldset>
</div>
<div id="result-data">
    <c:choose>
        <c:when test="${empty total}">

            <div class="padding-status">
                <fieldset>
                    <div id="result-bar">
                        <table border="0" width="100%">
                            <tr>
                                <td>ผลการค้นหา : 0 รายการ</td>
                                <td width="200px" align="right">หน้าที่ :
                                    <select>
                                        <option value="1" >1</option>
                                    </select>
                                    / 1 </td>
                                <td width="100px">
                                    <img src="theme/images/ar_left_abs_dis.gif" />
                                    <img src="theme/images/ar_left_dis.gif" />
                                    <img src="theme/images/ar_right_dis.gif" />
                                    <img src="theme/images/ar_right_abs_dis.gif" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </fieldset>
            </div>
        </c:when>
    </c:choose>
    <div class="padding-status">${pStatus}</div>
    <table border="0"  cellpadding="4" cellspacing="1">
        <tr style="background: #3B5998;color: #FFF">
            <th width="10px">ลำดับ</th>
            <th width="100px">ทะเบียนรถ</th>
            <th width="150px">จังหวัด</th>
            <th width="100px">ยี่ห้อ</th>
            <th width="100px">สี</th>
            <th width="300px">ผู้ถือครอง</th>

        </tr>
        <c:choose>
            <c:when test="${empty dataList}">
            </c:when>
            <c:otherwise>

                <c:forEach items="${dataList}" var="result" varStatus="i">
                    <tr id="${i.count}"
                        onmouseover="over('${i.count}');"
                        onmouseout="out('${i.count}','${i.count%2==0?"#FFFFFF":"#EEEFF4"}');"
                        ondblclick="edit('${result.plateFull}','${result.province}');"
                        bgcolor="${i.count%2==0?"#FFFFFF":"#EEEFF4"}">
                        <td align="center">${goto + i.count}</td>
                        <td align="center">${result.plateFull}</td>
                        <td align="center">${result.province}</td>
                        <td align="center">${result.brand}</td>
                        <td align="center">${result.color}</td>
                        <td>${result.ownerPrefix}
                            ${result.ownerFname} ${result.ownerLname}</td>
                    </tr>
                </c:forEach>
            </c:otherwise>
        </c:choose>
    </table>
</div>

<%@include file="theme/Footer.jsp" %>